<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>数据监控</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <%@include file="../include/commonFile.jsp" %>
</head><body>
<!--头部-->
<%@include file="../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
            <form class="layui-form" action="${ctx}/db/analyze/list.do" id="myForm" method="post">
                <input type="hidden" name="pageNo" id="pageNo"/>
            </form>
            <div class="list-content">
                <div class="cl">
                    <table class="layui-table">
                        <colgroup>
                            <col width="100">
                            <col width="100">
                            <col width="100">
                            <col width="100">
                            <col width="100">
                        </colgroup>
                        <thead>
                        <tr>
                            <th>表名</th>
                            <th>今天</th>
                            <th>本周</th>
                            <th>本月</th>
                            <th>总数</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach var="analyze" items="${list}">
                            <tr>
                                <td class="">
                                    <div class="dib ellipsis-1" title="${analyze.tableName}">${analyze.tableName}</div>
                                </td>
                                <td>
                                        ${analyze.today}
                                </td>
                                <td>
                                        ${analyze.week}
                                </td>
                                <td>
                                        ${analyze.month}
                                </td>
                                <td>
                                        ${analyze.rows}
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
            </div>
            <div id="page_content" class="page-container"></div>
            <form class="layui-form" method="post">
                <div class="f-search-bar">
                    <div class="search-container">
                        <ul class="search-form-content">
                            <li class="form-item-inline"><label class="search-form-lable">表名</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="tableName" id="tableName" autocomplete="off"
                                           class="layui-input" placeholder="表名">
                                </div>
                            </li>
                            <li class="form-item-inline">
                                <div class="sub-btns">
                                    <a class="layui-btn layui-btn-danger" href="javascript:submit()">确定</a>
                                    <a class="layui-btn layui-btn-normal" href="javascript:resetFunction('#viewForm')">重置</a>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </form>
            <div class="content mt15" id="charts" style="height:400px;"></div>
        </div><!--底部-->
        <%@include file="../include/footer.jsp" %>
    </section>
</div>



<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript" src="${ctx}/static/echarts-3.0/echarts.min.js"></script>
<script type="text/javascript" src="${ctx}/static/echarts-3.0/base_config.js"></script>
<script type="text/javascript">
    $(function () {
        //加载分页
        loadPageNew({elem: 'page_content', totalCount: '${page.totalCount}', limit: '${page.limit}', page: '${page.page}'});
    });

    function getDta(tableName) {
        $.get('${ctx}/db/analyze/countList.do', {tableName: tableName}, function (res) {
            var charts = echarts.init(document.getElementById('charts'));

            var option = {
                title: {
                    text: '近半月趋势图',
                },
                xAxis: {
                    data: res.data.dayList
                },
                series: [{
                    name: '数据量',
                    type: 'line',
                    data: res.data.dataList,
                }]
            };
            option = getEchartBaseLineOpt(option);
            charts.setOption(option);
            $("#tableName").val(res.data.tableName);
        })
    }

    getDta('');

    function submit() {
        var tableName = $("#tableName").val();
        getDta(tableName);
    }
</script>
<script type="text/javascript">
    txz.initHeader({
        nav:[{
            name: '数据监控',
            curr: true
        }],
        info:'<span class="f12">共<b id="totalCount">${page.totalCount}</b>条记录</span>'
    });
</script>
</body>
</html>